Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created sorting methods - insert, bubble and merge techniques #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Visiona
Copy link

@Visiona Visiona commented Jan 5, 2017

No description provided.

while temp_value != nil
temp_value = nil
(array.length - 1).times do |idx|
if array[idx] > array[idx + 1]
Copy link

@remis1889 remis1889 May 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To swap 2 elements, a and b in ruby - a, b = b, a.This will eliminate the use of temp_value variable.

merge_sort.rb Outdated

def merge(left_arr, right_arr)
new_arr = []
if left_arr != nil && right_arr != nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace if ! by unless and == nil by .nil?
unless left_arr.nil? || right_arr.nil?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants